<?php

namespace teach\service;

use Yii;

class Recharge
{
    /**
     * 插入一条充值记录
     * @param $recharge
     * @return int
     */
    public function rechargeInset($recharge)
    {
        return Yii::$app->db->createCommand()->insert('mall_recharge_record', $recharge)->execute();
    }

    /**
     * 获取一条订单
     * @param $out_trade_no
     * @return array|false
     */
    public function rechargeGetId($out_trade_no)
    {
        $sql= "SELECT * FROM mall_recharge_record WHERE out_trade_no = '{$out_trade_no}'";
        return Yii::$app->db->createCommand($sql)->queryOne();
    }

    /**
     * 获取4条信息
     * @return array
     */
    public function rechargeLists()
    {
        $sql = "SELECT * FROM mall_recharge_product WHERE status = 1 ORDER BY sort DESC LIMIT 3";
        return Yii::$app->db->createCommand($sql)->queryAll();
    }
}